<script>
import touzi from "../views/touzi.vue";
import girl from "@/assets/svg/girl.svg";
import man from "@/assets/svg/man.svg";
import config from "@/checkerboard";
import green from "@/assets/svg/green.svg";
import red from "@/assets/svg/red.svg";
import blue from "@/assets/svg/blue.svg";
import yellow from "@/assets/svg/yellow.svg";
import around from "@/assets/svg/yellow-around.svg";
import people from "@/components/people-container.vue";
import dice from "@/components/roll-dice.vue";
import popupNotification from '@/components/popupNotification.vue';
export default {
  components: {
    touzi,
    girl,
    man,
    green,
    red,
    blue,
    yellow,
    around,
    popupNotification,
  },

  data() {
    return {
      config,
      sex: 1,
    };
  },
  methods: {
    addTask() {
      alert("正在开发中，请稍待。");
    },
    /**
     * @param {{color:string,type:string}} item
     * @return {Component|string}
     */
    outputComponent(item) {
      if (item.type === "rectangle") {
        return item.color;
      } else if (item.type === "around") {
        return item.type;
      } else if (item.type === "piece") {
        return "div";
      } else if (item.type === "people") {
        return people;
      } else if (item.type === "dice") {
        return dice;
      }
    },
    diceChange(result) {
      alert(`性别:${this.sex ? "男" : "女"},结果:${result}`);
    },
  },
};
</script>

<template>
  <div class="div">
    <div class="popupNotification">
        <popupNotification /> 
    </div>
    <header class="header-bar">
      <h3>物业惊魂-保安大战保洁</h3>
      <p class="button" @click="addTask()">+自定义任务</p>
    </header>
    <div class="app-main">
      <div class="main">
        <div
          class="borard"
          :style="{ order: item.order }"
          v-for="(item, index) in config[0].value"
          :key="index"
          :ref="`plate-${index + 1}`"
        >
          <component
            :is="outputComponent(item)"
            :data="item"
            :sex="sex"
            @change="diceChange"
          ></component>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.div {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(
    300px circle at right top,
    rgb(255, 0, 153),
    rgb(36, 16, 30)
  );
  position: relative;
  .popupNotification{
    position: absolute;
    top: 25%;
    left: calc(50% - 39%);
    width: 78%;
    height: 206px;
    background-color: #E465AF;
  }
  header {
    width: 100%;
    height: 100px;
    line-height: 100px;
    position: relative;
    h3 {
      font-size: 20px;
      text-align: center;
      color: aliceblue;
      font-weight: 600;
      letter-spacing: 6px;
    }
  }
  .button {
    color: gray;
    border: none;
    font-size: 14px;
    position: absolute;
    top: 0;
    right: 10px;
  }
  .app-main {
    flex: 1;
    .main {
      height: 100%;
      padding: 20px 30px;
      display: grid;
      grid-template-rows: repeat(14, 1fr); /* 创建14行 */
      grid-template-columns: repeat(7, 1fr); /* 创建7列 */
      gap: 10px; /* 可选项，定义网格项之间的间隔 */
      .borard {
        width: 100%;
        height: 100%;
        display: flex;
        svg {
          height: 100%;
          width: 100%;
        }
      }
    }
  }
}
</style>
